package com.liux.rabbitmq.two;

import com.liux.rabbitmq.utils.RabbitMQUtil;
import com.rabbitmq.client.Channel;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @Date 2022/4/16 13:20
 * @Description
 *  大量发送消息的生产者
 **/
public class Task01 {
    public static final String QUEUE_NAME="hello";

    public static void main(String[] args) throws Exception {

        Channel channel = RabbitMQUtil.getChannel();
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);
        // 从控制台输入消息
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message =scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,message.getBytes(StandardCharsets.UTF_8));
            System.out.println("发生消息："+message+"  完成");
        }


    }

}
